package com.itheima.udp;

import java.io.IOException;
import java.net.*;

public class SockdetDemo01 {
    public static void main(String[] args) throws IOException {
        //UDP发送过程
        //1.创建发送端DatagramSocket对象
        DatagramSocket da = new DatagramSocket();
        //2，创建数据，数据打包DatagramFacket
        String s = "礼物读到";
        byte[] bytes = s.getBytes();
        InetAddress byName = InetAddress.getByName("10.254.7.120");
        int port = 1000;
        DatagramPacket dapa = new DatagramPacket(bytes, bytes.length, byName, port);
        //调用DatagramSocket对象发送
        da.send(dapa);
        //释放资源
        da.close();
    }
}
